package com.magnificent.atlantis.client.ui.planner.panels.configuration;

import javax.swing.*;
import java.util.List;

/**
 * User: Babanin
 * Date: 15.02.2009
 * Time: 21:45:28
 */
public class ListModel<T> extends AbstractListModel {
    private List<T> data;

    public ListModel(List<T> data) {
        this.data = data;
    }

    public int getSize() {
        return data.size();
    }

    public T getElementAt(int index) {
        return data.get(index);
    }

    public void update(int index) {
        fireContentsChanged(new Object(), index, index);
    }

    public void update(int... indexes) {
        for (int i : indexes) {
            fireContentsChanged(new Object(), i, i);
        }
    }

    public void update(){
        Object o = new Object();
        for(int i = 0; i < data.size(); i++){
            fireContentsChanged(o, i, i);
        }
    }
}
